<template>
	<view class="content" >
		<view v-if="show_main" class="main" >
			<u-index-list :scrollTop="scrollTop" >
					<view v-for="(item, index) in indexList" :key="index">
						<u-index-anchor :use-slot="true">
							<text class="anchor-text" :id="'index-'+item">{{item}}</text>
						</u-index-anchor>
						
						<view v-for="(item2,index2) in list[item]" @click="getCity" :data-name="item2.name" :key="index2" :class="'list-cell '+(index2 < list[item].length-1 ? 'bbo' : '')">
							{{item2.name}}
						</view>
					</view>
			</u-index-list>
		</view>
		<view style="height: 30px;"></view>
		<loading :loading="not_load"/><!--加载状态-->
	</view>
</template>

<script setup>
import { onLoad, onShow, onHide, onReachBottom, onPullDownRefresh,onPageScroll } from '@dcloudio/uni-app';
import { ref } from 'vue';	
import city from '@/utils/city-index.json';

const show_main=ref(true);
const not_load=ref(false);
const scrollTop=ref(0);
const indexList=ref(city.bac);
const list=ref(city.list);
//console.log(city);
//获取城市
const getCity=(e)=>{
	let city=e.currentTarget.dataset.name;
	uni.$vuex.state.globalData.businessCity=city;
	uni.navigateBack({data:1});
};
//页面加载时
onLoad(async (options)=>{
    loadPage(options,false);
});
//页面显示时执行
onShow(()=>{
	//console.log('语法糖onShow');
});
//页面隐藏时执行
onHide(()=>{
	//console.log('语法糖onHide');
});
/**
 * 加载接口数据
 * @param {Object} options  参数,对像数组
 * @param {Object} isPage   是否加载大于1页
 */
const loadPage=async (options,isPage)=>{
	let ret = await uni.$get('/appapi-sign-getstatus',options);
	console.log(ret);
	if(ret.error_code != 0){
		uni.$utils.showToast(ret.info);
		return;
	}
	show_main.value=true;
	not_load.value=true;
	result.value=ret.data;
};
/**
 * 模板属性跳转页面
 * @param {Object} e
 */
function goPage(event){
	topDropDownShow.value=false;
	uni.$utils.dataSetPage(event);
};
onPageScroll((e)=> {
	scrollTop.value = e.scrollTop;
});
const select=(e)=>{
	console.log(e);
};
</script>

<style  lang="scss">
page {
	
}
.list-cell {
	display: flex;
	box-sizing: border-box;
	width: 100%;
	padding: 10px 24rpx;
	overflow: hidden;
	color: #323233;
	font-size: 16px;
	line-height: 24px;
	background-color: #fff;
}
</style>
